﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleES
{
    public static class SqlSugarHelper
    {
        public static SqlSugarScope GetInstance()
        {
            SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
            {
                DbType = SqlSugar.DbType.MySql,
                ConnectionString = "server=192.168.0.250;port=3306;database=qr_bigscreen;user=root;password=qr_666_com;CharSet=utf8mb4;",
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute, //从特性读取主键自增信息
                MoreSettings = new ConnMoreSettings()
                {
                    PgSqlIsAutoToLower = false //数据库存在大写字段的 ，需要把这个设为false ，并且实体和字段名称要一样
                },
            },
            db =>
            {
                //单例参数配置，所有上下文生效
                //db.Aop.OnLogExecuting = (sql, pars) =>
                //{
                //    Console.WriteLine(sql);//输出sql
                //    Console.WriteLine();
                //};
                db.Ado.CommandTimeOut = 30; //单位秒
            });
            return sqlSugar;
        }
    }
}
